package org.budo.netty.servlet.server.websocket;

import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import javax.websocket.ClientEndpointConfig;
import javax.websocket.DeploymentException;
import javax.websocket.Endpoint;
import javax.websocket.Extension;
import javax.websocket.Session;
import javax.websocket.server.ServerContainer;
import javax.websocket.server.ServerEndpointConfig;

import lombok.extern.slf4j.Slf4j;

/**
 * @author lmw
 */
@Slf4j
public class BudoNettyServletWebsocketServerContainer implements ServerContainer {
    private int defaultMaxTextMessageBufferSize = 42;

    private long defaultMaxSessionIdleTimeout = 1000;

    private List<ServerEndpointConfig> endpoints = new ArrayList<ServerEndpointConfig>();

    @Override
    public void addEndpoint(ServerEndpointConfig serverConfig) throws DeploymentException {
        log.info("#32 addEndpoint, serverConfig=" + serverConfig);
        this.endpoints.add(serverConfig);
    }

    @Override
    public int getDefaultMaxTextMessageBufferSize() {
        return this.defaultMaxTextMessageBufferSize;
    }

    @Override
    public void setDefaultMaxTextMessageBufferSize(int maxTextMessageBufferSize) {
        log.info("#43 setDefaultMaxTextMessageBufferSize, maxTextMessageBufferSize=" + maxTextMessageBufferSize);

        this.defaultMaxTextMessageBufferSize = maxTextMessageBufferSize;
    }

    @Override
    public long getDefaultMaxSessionIdleTimeout() {
        return this.defaultMaxSessionIdleTimeout;
    }

    @Override
    public void setDefaultMaxSessionIdleTimeout(long maxSessionIdleTimeout) {
        log.info("#55 setDefaultMaxSessionIdleTimeout, maxSessionIdleTimeout=" + maxSessionIdleTimeout);

        this.defaultMaxSessionIdleTimeout = maxSessionIdleTimeout;
    }

    @Override
    public long getDefaultAsyncSendTimeout() {
        throw new RuntimeException();
    }

    @Override
    public void setAsyncSendTimeout(long timeoutmillis) {
        throw new RuntimeException();
    }

    @Override
    public Session connectToServer(Object annotatedEndpointInstance, URI path) throws DeploymentException, IOException {
        throw new RuntimeException();
    }

    @Override
    public Session connectToServer(Class<?> annotatedEndpointClass, URI path) throws DeploymentException, IOException {
        throw new RuntimeException();
    }

    @Override
    public Session connectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path) throws DeploymentException, IOException {
        throw new RuntimeException();
    }

    @Override
    public Session connectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig cec, URI path) throws DeploymentException, IOException {
        throw new RuntimeException();
    }

    @Override
    public int getDefaultMaxBinaryMessageBufferSize() {
        throw new RuntimeException();
    }

    @Override
    public void setDefaultMaxBinaryMessageBufferSize(int max) {
        throw new RuntimeException();
    }

    @Override
    public Set<Extension> getInstalledExtensions() {
        throw new RuntimeException();
    }

    @Override
    public void addEndpoint(Class<?> endpointClass) throws DeploymentException {
        throw new RuntimeException();
    }
}